package com.example.demo.demos.completion;

import io.modelcontextprotocol.server.McpServerFeatures;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.modelcontextprotocol.spec.McpSchema;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;

@Configuration
public class CodeCompletionCompletion {
    @Bean
    public List<McpServerFeatures.AsyncCompletionSpecification> myCompletions() {
        McpServerFeatures.AsyncCompletionSpecification completion = new McpServerFeatures.AsyncCompletionSpecification(
                new McpSchema.PromptReference("code-completion"),
                (exchange, request) -> {
//                    request.argument();
                    // Implementation that returns completion suggestions
                    McpSchema.CompleteResult r = new McpSchema.CompleteResult(
                            new McpSchema.CompleteResult.CompleteCompletion(
                                    Arrays.asList("First suggestion", "Second suggestion"), 2, false
                            ));
                    return Mono.just(r);
                }
        );

        return Arrays.asList(completion);
    }
}
